/*
* Copyright (C) 2024-2025 Uniontech Technology Co., Ltd.
*
* Author:      zhangbingyi <zhangbingyi@uniontech.com>
*
* Maintainer:  zhangbingyi <zhangbingyi@uniontech.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#include "switchaccounttipdialog.h"
#include "securitylevelchangedefinition.h"

//#include <DBlurEffectWidget>
//#include <DFontSizeManager>
//#include <DLabel>
//#include <DSuggestButton>
//#include <DTitlebar>
#include <QLabel>
#include <QPushButton>

#include <QVBoxLayout>

SwitchAccountTipDialog::SwitchAccountTipDialog(QWidget *parent)
    : QFrame(parent)
    , m_blurEffect(nullptr)
    , m_titleBar(nullptr)
{
    this->setAccessibleName("switchAccountTipDialog");

    // 初始化Ui
    initUI();
}

void SwitchAccountTipDialog::initUI()
{
    // 设置为Dialog
    setWindowFlags(Qt::Dialog);

    // 设置为阻态
    //    setWindowModality(Qt::ApplicationModal);

    // 背景设置为透明化
    setAttribute(Qt::WA_TranslucentBackground);

    // 设置边距及大小
    setContentsMargins(0, 0, 0, 0);
    setFixedWidth(420);
    setFixedHeight(180);

//    // 背景 模糊处理
//    m_blurEffect = new DBlurEffectWidget(this);
//    m_blurEffect->setBlendMode(DBlurEffectWidget::BehindWindowBlend);
//    m_blurEffect->resize(size());
//    m_blurEffect->lower();

    QVBoxLayout *mainLayout = new QVBoxLayout(this);
    mainLayout->setContentsMargins(0, 0, 0, 0);
    mainLayout->setSpacing(0);
    setLayout(mainLayout);

//    // 设置右上角关闭按钮
//    m_titleBar = new DTitlebar(this);
//    m_titleBar->setAccessibleName("switchAccountTipDialog_closeTitleBar");
//    m_titleBar->setBackgroundTransparent(true);
//    m_titleBar->setTitle("");
//    m_titleBar->setMenuVisible(false);
//    m_titleBar->setIcon(QIcon::fromTheme(DIALOG_TIP_YELLOW));

//    mainLayout->addWidget(m_titleBar, 0, Qt::AlignTop);

    // 标题
    QLabel *title = new QLabel("", this);
    title->setText(tr("Configure system security level"));
    title->setAccessibleName("switchAccountTipDialog_title");
    title->setContentsMargins(0, 0, 0, 0);
    QFont ft = title->font();
    ft.setBold(true);
    title->setFont(ft);
    mainLayout->addWidget(title, 0, Qt::AlignCenter);
    mainLayout->addSpacing(10);

    // 内容
    QLabel *content = new QLabel("", this);
    content->setWordWrap(true);
    content->setAccessibleName("switchAccountTipDialog_content");
    content->setContentsMargins(20, 0, 20, 0);
    content->setText(tr("You have enabled privilege separation, and only the security admin can disable the high security level. Please switch to that user and then disable it."));
    content->setAlignment(Qt::AlignCenter);
    mainLayout->addWidget(content);
    mainLayout->addSpacing(10);

    // 设置确定按钮
    QPushButton *btn = new QPushButton(this);
    btn->setText(tr("OK", "button"));
    btn->setAccessibleName("switchAccountTipDialog_okButton");
    btn->setFixedWidth(380);
    mainLayout->addWidget(btn, 0, Qt::AlignCenter);
    mainLayout->addSpacing(10);

    connect(btn, SIGNAL(clicked()), this, SLOT(close()));
}
